package com.hnjz.common;

import javax.servlet.http.HttpServletRequest;

/**
 * 获取IP工具类
 * @author newbie
 *
 */
public class IPUtil {

	public static String getIpAddr(HttpServletRequest request){
		String ip=request.getHeader("x-forwarded-for");
		if(ip == null || ip.length() == 0 || "unkown".equalsIgnoreCase(ip)){
			ip=request.getHeader("Proxy-Client-IP");
		}
		if(ip == null || ip.length() == 0 || "unkown".equalsIgnoreCase(ip)){
			ip=request.getHeader("WL-Proxy-Client-IP");
		}
		if(ip == null || ip.length() == 0 || "unkown".equalsIgnoreCase(ip)){
			ip=request.getRemoteAddr();
		}
		if(ip.indexOf("0:") != -1){
			ip="本地";
		}
		return ip;
	}
}
